package com.jsgt.greekfire.common.util

import android.content.Context
import com.jsgt.greekfire.R
import com.jsgt.greekfire.dialog.SecurityPwdDialog

class PayPassWordUtil {
    companion object {
        fun show(
            context: Context,
            coinName: String,
            amount: String,
            onClickListener: (payPassword: String) -> Unit
        ) {
            var pwdDialog: SecurityPwdDialog?
            pwdDialog = SecurityPwdDialog(context, R.style.dialog)
            pwdDialog.nameTv?.text = coinName
            pwdDialog.numberTv?.text = amount
            pwdDialog.inputCallback = object : SecurityPwdDialog.InputCallback {
                override fun callBack(result: String) {
                    onClickListener(result)
                }
            }
            pwdDialog.setOnDismissListener {
                pwdDialog = null
            }
            pwdDialog?.show()

//            var pwdDialog: Dialog?
//            val contentView =
//                LayoutInflater.from(context).inflate(R.layout.dialog_input_pay_pwd, null, false)
//            pwdDialog = DialogUtil.show(context!!, contentView)
//            pwdDialog.setOnDismissListener {
//                pwdDialog = null
//            }
//            pwdDialog?.setCanceledOnTouchOutside(true)
//            pwdDialog?.setCancelable(true)
//            pwdDialog?.show()
//
//            contentView.findViewById<TextView>(R.id.check_pwd_tv_cancel).setOnClickListener {
//                pwdDialog?.dismiss()
//            }
//
//            contentView.findViewById<TextView>(R.id.check_pwd_tv).setOnClickListener {
//                val pwd = contentView.findViewById<EditText>(R.id.pwd_et).text.toString().trim()
//                if (TextUtils.isEmpty(pwd)) {
//                    ToastUtils.show(context.getString(R.string.input_pwd_error_null))
//                } else {
//                    pwdDialog?.dismiss()
//                    onClickListener.invoke(pwd)
//                }
//            }
        }
    }
}